package com.example.cloud.webflux.reactor;

import com.sun.security.ntlm.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RequestPredicates.accept;

/**
 * 路由
 *
 * @author tongyufu
 * @since 2019年6月11日 下午11:49:52
 */
@Configuration
public class PersonRouter {

    @Bean
    public RouterFunction<ServerResponse> router(PersonHandler personHandler) {
        return RouterFunctions.route(GET("/list").and(accept(MediaType.APPLICATION_JSON)), personHandler::listPeople);
    }
}
